package com.pucheng.bracelet.app.database.repository

import androidx.annotation.WorkerThread
import com.pucheng.bracelet.app.App
import com.pucheng.bracelet.app.database.dao.StepDao
import com.pucheng.bracelet.data.bean.StepsBean
import kotlinx.coroutines.flow.Flow

/**
 * 数据库集合
 */
class DBRepository() {

    //步数
    private val stepsDao: StepDao = App.instance.database.stepsDao()

    //查询所有数据
    val allDataTo7DayToStep: Flow<List<StepsBean>> = stepsDao.get7Days()

    //查询本周的数据所有数据
    val getWeekStepsData: Flow<List<StepsBean>> = stepsDao.getWeekData()

    //查询所有数据
    val allDataToStep: Flow<List<StepsBean>> = stepsDao.getAll()

//    //查询指定日期的数据
    fun getStepsInfoToDate(date:String) = stepsDao.getDataToDate(date)

//    //查询指定日期的数据
    fun getStepsInfoToDate2(date:String) = stepsDao.getDataToDate2(date)

    // 插入数据
    @Suppress("RedundantSuspendModifier")
    @WorkerThread
    suspend fun insertSteps(stepsBean: StepsBean) {
            stepsDao.insert(stepsBean)
    }


}